package com.ggdog.blog.Controller;


import com.ggdog.blog.POJO.Result;
import com.ggdog.blog.POJO.VO.CommentDTO;
import com.ggdog.blog.Services.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    // 获取指定文章的评论列表

    @GetMapping("/getCommentsByArticleId")
    public List<CommentDTO> getCommentsByArticleId(@RequestParam int articleId) {
        return commentService.getCommentsByArticleId(articleId);
    }

    // 提交评论

    @PostMapping("/addCommentByArticleId")
    public Result<String> addCommentByArticleId(@RequestBody Map<String, Object> requestData) {

        return commentService.addCommentByArticleId(requestData);
    }
}